package com.hzdesk.media.koreabatchmatvector.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.hzdesk.media.koreabatchmatvector.R;
import com.hzdesk.media.koreabatchmatvector.bean.WifiBean;
import com.hzdesk.media.koreabatchmatvector.inter.ICancelSaveDialogInter;

/**
 * Created by Administrator on 2018/8/3.
 * 杭州席媒科技有限公司  Developers  刘传华  10
 * 佛祖镇楼 bug辟易
 */

public class CancelSaveDialog extends Dialog implements View.OnClickListener{
    private Context mContext;
    private TextView tv_wifi_name;
    private TextView tv_wifi_state;
    private TextView tv_wifi_cancel_save;
    private TextView tv_wifi_cancel;
    private WifiBean tWifiBean;
    private ICancelSaveDialogInter mICancelSaveDialogInter = null;

    public void setmICancelSaveDialogInter(ICancelSaveDialogInter mICancelSaveDialogInter) {
        this.mICancelSaveDialogInter = mICancelSaveDialogInter;
    }

    public CancelSaveDialog(@NonNull Context context, int themeResId, WifiBean mWifiBean) {
        super(context, themeResId);
        mContext = context;
        tWifiBean = mWifiBean;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_cancel_save, null);
        setContentView(view);
        initView(view);
    }

    private void initView(View view) {
        tv_wifi_name = view.findViewById(R.id.dialog_cancel_save_tv_wifi_name);
        tv_wifi_state = view.findViewById(R.id.dialog_cancel_save_tv_wifi_state);
        tv_wifi_cancel_save = view.findViewById(R.id.dialog_cancel_save_tv_wifi_cancel_save);
        tv_wifi_cancel = view.findViewById(R.id.dialog_cancel_save_tv_wifi_cancel);
        tv_wifi_name.setText(tWifiBean.getWifiName());
        tv_wifi_state.setText(tWifiBean.getState());

        tv_wifi_cancel_save.setOnClickListener(this);
        tv_wifi_cancel.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.dialog_cancel_save_tv_wifi_cancel_save:
                if(mICancelSaveDialogInter != null ){
                    mICancelSaveDialogInter.OnClickedDetermine(tWifiBean);
                }
                break;
            case R.id.dialog_cancel_save_tv_wifi_cancel:
                if(mICancelSaveDialogInter != null ){
                    mICancelSaveDialogInter.OnClickedCancel();
                }
                break;
        }
    }
}
